﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using VOL.Domain.IServices.QualityManagement;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers.QualityManagement
{
    /// <summary>
    /// 来料检验
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class IncominginspectionController : ControllerBase
    {
        private IIncominginspectionService _incominginspectionService;

        public IncominginspectionController(IIncominginspectionService incominginspectionService)
        {
            _incominginspectionService = incominginspectionService;
        }

        /// <summary>
        /// 来料检验新增
        /// </summary>
        /// <param name="incominginspection"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddIncominginspection([FromBody]Incominginspection incominginspection)
        {
            return await _incominginspectionService.AddIncominginspection(incominginspection);
        }
        /// <summary>
        /// 来料检验删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<int> DeleteIncominginspection(int id)
        {
            return await _incominginspectionService.DeleteIncominginspection(id);
        }
        /// <summary>
        /// 来料检验显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Incominginspection>> GetAllIncominginspection(string? incomingNumber, string? incomingName, int pageIndex = 1, int pageSize = 5)
        {
            return await _incominginspectionService.GetAllIncominginspection(incomingNumber, incomingName, pageIndex, pageSize);
        }
        /// <summary>
        /// 来料检验修改
        /// </summary>
        /// <param name="incominginspection"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateIncominginspection([FromBody]Incominginspection incominginspection)
        {
            return await _incominginspectionService.UpdateIncominginspection(incominginspection);
        }


    }
}
